module.exports = function (app, models, $, db, nm) {
     //购物车详情
	app.get('/v2/cart',(req,res) => {
        var query = {
			pageSize:req.query.pageSize || 10,
			pageNum:req.query.pageNum || 1,
			unitId:req.unitId,
            memberId:req.query.memberId
		}
		models.cart.list(query, ret => {
			res.send(ret)
		},{
            join:{
                skuId: {
                    type: 'INNER ',
                    name: 'sku',
                    key: 'skuId',
                    projection: {
                        productName: 1,
                        salePrice: 1,
                        imgs: 1,
                        props: 1,
                        skuSpecification:1
                    }
                }
            },
            projection: {
				skuId: 1,
				num: 1,
                _id:1
			}
        })
	})
    //新增购物车
	app.post('/v2/cart', (req, res) => {
		req.body.unitId = req.unitId
			models.cart.insert(req.body, ret => {
                res.send(ret)
            })
	})
    //删除购物车
	app.delete('/v2/cart',(req,res) => {
		models.cart.remove({_id:req.query._id}, ret => {
			res.send(ret)
		})
	})
    }